/*
 * tarm_iic.h
 *
 *  Created on: 2019��10��26��
 *      Author: AN
 */

#ifndef SRC_MIDDLEWARE_TARM_IO_H_
#define SRC_MIDDLEWARE_TARM_IO_H_

#include "at32f4xx.h"


//gpio
#define X_STP_PORT GPIOA
//#define Y_STP_PORT GPIOE
#define Y_STP_PORT GPIOB
#define Z_STP_PORT GPIOB

//#define X_DIR_PORT GPIOE
#define X_DIR_PORT GPIOB
#define Y_DIR_PORT GPIOB
#define Z_DIR_PORT GPIOA

#define EN_STEER_PORT GPIOA

#define X_LIM_PORT GPIOC
#define Y_LIM_PORT GPIOA

#define SYSLED_PORT GPIOB

//PIN
#define X_STP_PIN GPIO_Pins_10
#define Y_STP_PIN GPIO_Pins_3
#define Z_STP_PIN GPIO_Pins_5

//#define X_DIR_PIN GPIO_Pins_5
#define X_DIR_PIN GPIO_Pins_4
#define Y_DIR_PIN GPIO_Pins_10
#define Z_DIR_PIN GPIO_Pins_8

#define EN_STEER_PIN GPIO_Pins_9

#define X_LIM_PIN GPIO_Pins_7
#define Y_LIM_PIN GPIO_Pins_15

#define SYSLED_PIN GPIO_Pins_0

//SET
#define X_STP_SET GPIO_SetBits(X_STP_PORT, X_STP_PIN)
#define Y_STP_SET GPIO_SetBits(Y_STP_PORT, Y_STP_PIN)
#define Z_STP_SET GPIO_SetBits(Z_STP_PORT, Z_STP_PIN)

#define X_DIR_SET GPIO_SetBits(X_DIR_PORT, X_DIR_PIN)
#define Y_DIR_SET GPIO_SetBits(Y_DIR_PORT, Y_DIR_PIN)
#define Z_DIR_SET GPIO_SetBits(Z_DIR_PORT, Z_DIR_PIN)

#define EN_STEER_SET GPIO_SetBits(EN_STEER_PORT, EN_STEER_PIN)

#define SYSLED_SET GPIO_SetBits(SYSLED_PORT, SYSLED_PIN)

//RESET
#define X_STP_RESET GPIO_ResetBits(X_STP_PORT, X_STP_PIN)
#define Y_STP_RESET GPIO_ResetBits(Y_STP_PORT, Y_STP_PIN)
#define Z_STP_RESET GPIO_ResetBits(Z_STP_PORT, Z_STP_PIN)

#define X_DIR_RESET GPIO_ResetBits(X_DIR_PORT, X_DIR_PIN)
#define Y_DIR_RESET GPIO_ResetBits(Y_DIR_PORT, Y_DIR_PIN)
#define Z_DIR_RESET GPIO_ResetBits(Z_DIR_PORT, Z_DIR_PIN)

#define EN_STEER_RESET GPIO_ResetBits(EN_STEER_PORT, EN_STEER_PIN)

#define SYSLED_RESET GPIO_ResetBits(SYSLED_PORT, SYSLED_PIN)

//GET
#define X_LIM GPIO_ReadInputDataBit(X_LIM_PORT, X_LIM_PIN)
#define Y_LIM GPIO_ReadInputDataBit(Y_LIM_PORT, Y_LIM_PIN)

/************ function **************/
void SteeringIO_Init(void);

#endif /* SRC_MIDDLEWARE_TARM_IIC_H_ */
